package com.app.controller;


import com.app.common.IndustryTool;
import com.app.model.CusWorkExperienceModel;
import com.app.model.CustomerModel;
import com.app.model.StreetModel;
import com.app.model.UserModel;
import com.app.service.*;
import com.app.util.CommonHelp;
import com.app.util.Result;
import com.app.util.TokenUtils;
import lombok.Data;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;


@Controller
@RestController
@Data
public class StreetController {

    @Autowired
    StreetService streetService;
    @Autowired
    JobPublishService jobPublishService;

    //统计街道岗位数量
    @GetMapping("/getStreetList")
    public Object getStreetList() throws ParseException {
        List<StreetModel> list = streetService.getAll();
        for (int i = 0; i < list.size(); i++) {
            int count = jobPublishService.getCountByStreetId(list.get(i).getId());
            list.get(i).setCount(count);
        }
        return Result.success(list);

    }

    @GetMapping("/getStreetData")
    public Result<Object> getStreetData() throws ParseException {
        List<StreetModel> list = streetService.getAll();
        return Result.success(list);

    }
}
